package cn.edu.flink.scala.tutorial.transformer

import cn.edu.flink.scala.tutorial.source.Event
import org.apache.flink.streaming.api.scala._
import org.apache.flink.util.Collector

object 基本转换算子 {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI()
    env.setParallelism(1)

    val events = List(
      Event("Mary", "home/", 10000L),
      Event("Mary", "cart/", 20000L))

    val eventsDS = env.fromCollection(events)

    eventsDS.map(_.user).print("map")
    eventsDS.filter(_.url == "home/").print("filter")
    eventsDS.flatMap((events, collector:Collector[String]) => collector.collect(events.user)).print("flatmap")

    env.execute("基本转换算子")
  }
}
